<?php echo $header; ?><?php echo $column_left; ?><?php echo $column_right; ?>
<div id="content" class="product">
  <div class="top">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center">
      <h1 class="product"><?php echo $heading_title; ?></h1>
    </div>
  </div>
  <div class="middle">
    <div style="width: 100%; margin-bottom: 30px;">
      <table style="width: 100%; border-collapse: collapse;">
        <tr>
          <td style="text-align: center; width: 1%; vertical-align: top;"><a href="<?php echo $popup; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $thumb; ?>" alt="<?php echo $heading_title; ?>" id="image" /></a></td>
          <td style="padding-left: 15px; width: 50%; vertical-align: top;"><table width="100%">
              <?php if ($display_price) { ?>
              <tr>
                <td style="font-size:14px;"><b><?php echo $text_price; ?></b></td>
                <td style="font-size:14px;"><?php if (!$special) { ?>
                  <span style="color: #900; font-weight: bold;"><?php echo $price; ?></span>
                  <?php } else { ?>
                  <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $price; ?></span> <span style="color: #F00;font-weight: bold;"><?php echo $special; ?></span>
                  <?php } ?></td>
              </tr>
              <?php } ?>
              <tr>
<!--			<td><b><?php echo $text_tax; ?></b></td>
				<td><?php echo $tax; ?></td>
              </tr> -->
              <tr>
                <td><b><?php echo $text_availability; ?></b></td>
                <td><?php echo $stock; ?></td>
              </tr>
              <tr>
                <td><b><?php echo $text_model; ?></b></td>
                <td><?php echo $model; ?></td>
              </tr>
              <?php if ($manufacturer) { ?>
              <tr>
                <td><b><?php echo $text_manufacturer; ?></b></td>
                <td><a href="<?php echo $manufacturers; ?>"><?php echo $manufacturer; ?></a></td>
              </tr>
              <?php } ?>
              <tr>
                <td><b><?php echo $text_average; ?></b></td>
                <td><?php if ($average) { ?>
                  <img src="catalog/view/theme/default/image/stars_<?php echo $average . '.png'; ?>" alt="Đánh giá: <?php echo $text_stars; ?>" style="margin-top: 2px;" title="Đánh giá: <?php echo $text_stars; ?>" />
                  <?php } else { ?>
                  <img src="catalog/view/theme/default/image/stars_0.png" alt="Đánh giá: <?php echo $text_stars; ?>" style="margin-top: 2px;" title="Đánh giá: <?php echo $text_stars; ?>" />
                  <?php } ?></td>
              </tr>
            </table>
            <br />
            <?php if ($display_price) { ?>
            <form action="<?php echo $action; ?>" method="post" enctype="multipart/form-data" id="product">
              <?php if ($options) { ?>
              <b><?php echo $text_options; ?></b><br />
              <div class="content4">
                <table style="width: 100%;">
                  <?php foreach ($options as $option) { ?>
                  <tr>
                    <td><?php echo $option['name']; ?>:<br />
                      <select name="option[<?php echo $option['option_id']; ?>]">
                        <?php foreach ($option['option_value'] as $option_value) { ?>
                        <option value="<?php echo $option_value['option_value_id']; ?>"><?php echo $option_value['name']; ?>
                        <?php if ($option_value['price']) { ?>
                        <?php echo $option_value['prefix']; ?><?php echo $option_value['price']; ?>
                        <?php } ?>
                        </option>
                        <?php } ?>
                      </select></td>
                  </tr>
                  <?php } ?>
                </table>
              </div>
              <?php } ?>
              <?php if ($display_price) { ?>
              <?php if ($discounts) { ?>
              <b><?php echo $text_discount; ?></b><br />
              <div class="content3">
                <table style="width: 100%;">
                  <tr>
                    <td style="text-align: right;"><b><?php echo $text_order_quantity; ?></b></td>
                    <td style="text-align: right;"><b><?php echo $text_price_per_item; ?></b></td>
                  </tr>
                  <?php foreach ($discounts as $discount) { ?>
                  <tr>
                    <td style="text-align: right;"><?php echo $discount['quantity']; ?></td>
                    <td style="text-align: right;"><?php echo $discount['price']; ?></td>
                  </tr>
                  <?php } ?>
                </table>
              </div>
              <?php } ?>
              <?php } ?>
              <div class="content2"><?php echo $text_qty; ?>
                <input type="text" name="quantity" size="3" value="1" />
                <a onclick="$('#product').submit();" id="add_to_cart" class="button"><span><?php echo $button_add_to_cart; ?></span></a></div>
              <input type="hidden" name="product_id" value="<?php echo $product_id; ?>" />
              <input type="hidden" name="redirect" value="<?php echo $redirect; ?>" />
            </form>
<!-- AddThis Button BEGIN -->
<div class="content2" style="padding-bottom:0px;"><div class="addthis_toolbox addthis_default_style">
<a class="addthis_button_facebook_like" fb:like:layout="button_count" style="width:90px;"></a>
<a class="addthis_button_google_plusone" g:plusone:size="medium" style="width:90px;"></a>
</div>
</div>
<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3cb2660ca16d89"></script>
<!-- AddThis Button END -->
            <?php } ?></td>
        </tr>
      </table>
    </div>
  </div>
  <div class="bottom">
    <div class="left"></div>
    <div class="right"></div>
    <div class="center"></div>
  </div>
</div>
<div id="content">
    <div class="tabs"><a tab="#tab_description"><?php echo $tab_description; ?></a><a tab="#tab_image"><?php echo $tab_image; ?></a><a tab="#tab_review"><?php echo $tab_review; ?></a></div>
    <div id="tab_description" class="tab_page"><?php echo $description; ?></div>
    <div id="tab_review" class="tab_page">
      <div id="review"></div>
      <div class="heading" id="review_title"><?php echo $text_write; ?></div>
      <div class="content2"><b><?php echo $entry_name; ?></b><br />
        <input type="text" name="name" value="" />
        <br />
        <br />
        <b><?php echo $entry_review; ?></b>
        <textarea name="text" style="width: 99%;" rows="8"></textarea>
        <span style="font-size: 11px;"><?php echo $text_note; ?></span><br />
        <br />
        <b><?php echo $entry_rating; ?></b> <span><?php echo $entry_bad; ?></span>&nbsp;
        <input type="radio" name="rating" value="1" style="margin: 0;" />
        &nbsp;
        <input type="radio" name="rating" value="2" style="margin: 0;" />
        &nbsp;
        <input type="radio" name="rating" value="3" style="margin: 0;" />
        &nbsp;
        <input type="radio" name="rating" value="4" style="margin: 0;" />
        &nbsp;
        <input type="radio" name="rating" value="5" style="margin: 0;" />
        &nbsp; <span><?php echo $entry_good; ?></span><br />
        <br />
        <b><?php echo $entry_captcha; ?></b><br />
        <input type="text" name="captcha" value="" />
        <br />
        <img src="index.php?route=product/product/captcha" id="captcha" /></div>
      <div class="buttons">
        <table>
          <tr>
            <td align="right"><a onclick="review();" class="button"><span><?php echo $button_continue; ?></span></a></td>
          </tr>
        </table>
      </div>
    </div>
    <div id="tab_image" class="tab_page" style="text-align:center;">
		<?php if ($images) { ?> 
			<?php foreach ($images as $image) { ?>
			<div class="img">
			<a href="<?php echo $image['popup']; ?>" title="<?php echo $heading_title; ?>" class="fancybox" rel="fancybox"><img src="<?php echo $image['thumb']; ?>" title="<?php echo $heading_title; ?>" alt="<?php echo $heading_title; ?>" /></a>
			</div>
			<?php } ?>
		<?php } else { ?>
			<div class="content2"><?php echo $text_no_images; ?></div>
		<?php } ?>
		<div style="clear:both;"></div>
    </div>
<?php if($tags) { ?>
	<?php for ($i=0; $i < sizeof($tags); $i++) { ?>
		<?php if($i==0 && $tags[$i]['keyword']) { echo "<b>Tags:</b>"; } elseif($i!=0) { echo ", "; } ?>
		<a href="<?php echo $tags[$i]['href']; ?>"><?php echo $tags[$i]['keyword']; ?></a>
	<?php } ?>
<?php } ?>
</div>
<div id="content">
	<div class="heading"><?php echo $tab_related; ?></div>
    <div id="product_related">
      <?php if ($products) { ?>
     <?php for ($i = 0; $i < sizeof($products); $i = $i + 3) { ?>
      <ul class="list">
        <?php for ($j = $i; $j < ($i + 3); $j++) { ?>
        <?php if (isset($products[$j])) { ?>
		<li<?php if($j == $i+2) {echo ' class="right"';} ?>>
          <a href="<?php echo $products[$j]['href']; ?>"><img src="<?php echo $products[$j]['thumb']; ?>"  alt="<?php echo $products[$j]['name']; ?>" /></a><br />
          <a href="<?php echo $products[$j]['href']; ?>"><?php echo $products[$j]['name']; ?></a><br />
          <?php if ($display_price) { ?>
          <?php if (!$products[$j]['special']) { ?>
          <span style="color: #900; font-weight: bold;"><?php echo $products[$j]['price']; ?></span><br />
          <?php } else { ?>
          <span style="color: #900; font-weight: bold; text-decoration: line-through;"><?php echo $products[$j]['price']; ?></span> <span style="color: #F00;"><?php echo $products[$j]['special']; ?></span>
          <?php } ?>
          <?php } ?>
		</li>
          <?php } ?>
        <?php } ?>
      </ul>
      <?php } ?>
	  <div style="clear:both;"></div>
<div class="buttons">
      <table>
        <tbody><tr>
          <td align="right"><a href="<?php echo $xemtatca; ?>" class="button"><span><?php echo $text_xemtatca; ?></span></a></td>
        </tr>
      </tbody></table>
    </div>
      <?php } else { ?>
      <div class="content2"><?php echo $text_no_related; ?></div>
      <?php } ?>
	</div>
</div>
<script type="text/javascript"><!--
$('a#add_to_cart.button').click(function(event) {
	$('.cart-content').css("display",'block');
	return false;
});
//--></script>
<script type="text/javascript"><!--
$('#review .pagination a').live('click', function() {
	$('#review').slideUp('slow');
		
	$('#review').load(this.href);
	
	$('#review').slideDown('slow');
	
	return false;
});			

$('#review').load('index.php?route=product/product/review&product_id=<?php echo $product_id; ?>');

function review() {
	$.ajax({
		type: 'post',
		url: 'index.php?route=product/product/write&product_id=<?php echo $product_id; ?>',
		dataType: 'json',
		data: 'name=' + encodeURIComponent($('input[name=\'name\']').val()) + '&text=' + encodeURIComponent($('textarea[name=\'text\']').val()) + '&rating=' + encodeURIComponent($('input[name=\'rating\']:checked').val() ? $('input[name=\'rating\']:checked').val() : '') + '&captcha=' + encodeURIComponent($('input[name=\'captcha\']').val()),
		beforeSend: function() {
			$('.success, .warning').remove();
			$('#review_button').attr('disabled', 'disabled');
			$('#review_title').after('<div class="wait"><img src="catalog/view/theme/default/image/loading_1.gif" alt="" /> <?php echo $text_wait; ?></div>');
		},
		complete: function() {
			$('#review_button').attr('disabled', '');
			$('.wait').remove();
		},
		success: function(data) {
			if (data.error) {
				$('#review_title').after('<div class="warning">' + data.error + '</div>');
			}
			
			if (data.success) {
				$('#review_title').after('<div class="success">' + data.success + '</div>');
								
				$('input[name=\'name\']').val('');
				$('textarea[name=\'text\']').val('');
				$('input[name=\'rating\']:checked').attr('checked', '');
				$('input[name=\'captcha\']').val('');
			}
		}
	});
}
//--></script>
<script type="text/javascript"><!--
$.tabs('.tabs a'); 
//--></script>
<?php echo $footer; ?> 